﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LunwenYun.Infrastructure.Entities.Entity;

namespace LunwenYun.Infrastructure.Entities.Cache
{
    public class IndustryCSCache : EntitiesCache<IndustryCS>
    {
        protected override bool ValidateParameter(params string[] keys)
        {
            return keys.Length == 1 && !String.IsNullOrEmpty(keys[0]);
        }

        protected override IndustryCS LoadDataItem(params string[] keys)
        {
            if (ValidateParameter(keys))
            {
                string userName = keys[0];
                var cs = new IndustryCS().Find(c => c.UserName == userName);
                return cs;
            }
            return null;
        }

        protected override string BuildKey(params string[] keys)
        {
            if (ValidateParameter(keys))
            {
                return String.Format("GetIndustryCSEntity_{0}", keys[0]);
            }
            return string.Empty;
        }

        protected override string BuildKey(IndustryCS data)
        {
            if (data != null)
            {
                return BuildKey(data.UserName);
            }
            return string.Empty;
        }
    }
}
